package com.tablefood.action;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.tablefood.domain.ShopCart;
import com.tablefood.domain.ShopOrder;
import com.tablefood.domain.ShopOrderDetail;
import com.tablefood.domain.ShopProduct;
import com.tablefood.domain.ShopProfile;
import com.tablefood.domain.ShopUser;
import com.tablefood.service.CartService;
import com.tablefood.service.OrderDetailService;
import com.tablefood.service.OrderService;
import com.tablefood.service.ProductService;
import com.tablefood.service.ProfileService;
import com.tablefood.service.UserService;
import com.tablefood.utils.PageCartBean;
import com.tablefood.utils.PageOrderBean;
import com.tablefood.utils.PageUserBean;
import com.tablefood.utils.ResultUtils;

public class OrderAction extends ActionSupport {

  private ShopUser user ; 
  private ShopOrder shopOrder ;
  private ShopOrderDetail shopOrderDetail;
  private ShopProduct shopProduct;
  private ShopProfile shopProfile;
  private ShopCart shopCart;
   
  private int cartNum = 0 ;
 
  
  private String province;
  private String city;
  private String addressDetails;
  
  private List<ShopCart> notPayCart = null;
  private PageCartBean pageCartBean;
  private int page = 1;
  
  private PageOrderBean pageOrderBean;
  private List<ShopOrder> listOrder ;
  private long orderid;
  
  //Setting页所需的变量
  private List<ShopOrder> setting_PayOrder;  //已支付订单
  private List<ShopOrder> setting_NotPayOrder;//未支付订单
  private int selectFalg;                   //Setting页选择标志
  
  @Resource
  private OrderService orderService;
  @Resource
  private OrderDetailService orderDetailService;
  @Resource
  private ProductService productService;
  @Resource
  private ProfileService profileService;
  @Resource
  private CartService cartService;
  @Resource
  private UserService userService;
  
  //向购物车中添加商品
  public String Add() throws Exception {
	  
	// 获取post请求的数据
	Map<String, String> param = new HashMap<String, String>();
	HttpServletRequest request = ServletActionContext.getRequest();
	Map<String, String[]> params = request.getParameterMap();
	for (String key : params.keySet()) {
		String[] values = params.get(key);
		for (int i = 0; i < values.length; i++) {
			param.put(key, values[i]);

		}
	}
	  
	Map<String, Object> map = new HashMap<String, Object>();
	if (param.get("userid") == "null") {
		map.put("status", -1);
		ResultUtils.toJson(ServletActionContext.getResponse(), map);
		return null;
	}
	
	
	String userid = param.get("userid");//用户编号
	String productid = param.get("productid");//商品编号
	 
	user = userService.getUserByUserId(Long.parseLong(userid));
	shopProduct = productService.searchProducts(Long.parseLong(productid));
	
    System.out.println("---开始添加商品---"); 
    System.out.println("1.用户是否登录，检查userid："+userid);
    System.out.println("2.商品编号：productid:"+productid);
    
    //先查userid的用户的未支付的订单是否存在 
    if(!userid.equals("null")){
        
      List<ShopOrder> result = orderService.searchOrder(userid,"0");
      ShopOrder searchOrder = null ;
      
      //存在未支付的订单
      if(result!=null){
        System.out.println("查询有结果");
        searchOrder = result.get(0);
        System.out.println("未支付订单号是否存在？："+searchOrder.getOrderid());
      }
      
      //在未支付订单中找是否为重复的商品
      if(searchOrder!=null){
        
        String orderid = Long.toString(searchOrder.getOrderid());
        
        List<ShopOrderDetail> resultOfDetail = orderDetailService.searchOrderDetail(orderid,productid);
        ShopOrderDetail orderDetail = null ;//某一个商品的订单详细
         
        
        //若存在，详细和购物车都加1，修改总价
        if(resultOfDetail!=null){
          //更新时间
          Timestamp updateTime = new Timestamp(System.currentTimeMillis()); 
          //更新订单详细
          orderDetail = resultOfDetail.get(0);
          int i = orderDetail.getProductnum()+1;
          orderDetail.setProductnum(i);
          orderDetail.setUpdateTime(updateTime);
          orderDetailService.updateOrderDetail(orderDetail);
          
          //更新订单总价
          double amount = orderDetail.getPrice();
          searchOrder.setAmount(searchOrder.getAmount()+amount);
          searchOrder.setUpdateTime(updateTime);
          orderService.updateOrder(searchOrder);
          
          //更新购物车信息-根据userid和productid查询到购物车-找到某一商品的购物车
          List<ShopCart> resultCart = cartService.searchCartAboutProduct(userid, productid);
          
          if(resultCart!=null)
            shopCart = resultCart.get(0);
          
          int num = shopCart.getProductnum()+1;
          shopCart.setProductnum(num);
          shopCart.setUpdateTime(updateTime);
          cartService.updateCart(shopCart);
           
         //页面中显示购物中的商品种类的数量
          List<ShopCart> resultCart2 = cartService.searchCartByUserid(userid);
          if(resultCart2!=null){
            HttpSession session = ServletActionContext.getRequest().getSession();
            session.setAttribute("cartNum",resultCart2.size());
            map.put("cartNum",resultCart2.size());
          }
          
        }else{//表中没有该类商品，则新增一个商品详细和购物车
          
          //新增一个订单详细
          System.out.println("新增一个订单详细");
          System.out.println("详细外键-订单号："+shopOrderDetail.getShopOrder().getOrderid());
          System.out.println("商品编号："+shopProduct.getProductid());
          System.out.println("商品名称："+shopProduct.getTitle());
          System.out.println("商品单价："+shopProduct.getPrice());
          
          shopOrderDetail.setShopProduct(shopProduct);
          shopOrderDetail.setPrice(shopProduct.getPrice());
          shopOrderDetail.setProductnum(1);
          shopOrderDetail.setShopOrder(searchOrder);
          //添加一个新的详细
          shopOrderDetail = orderDetailService.insertOrderDetail(shopOrderDetail);

          //新增一个购物车中的商品行
           
          shopCart.setShopUser(user);
          shopCart.setShopProduct(shopProduct);
          shopCart.setProductnum(1);
          shopCart.setPrice(shopProduct.getPrice());
          shopCart.setTitle(shopProduct.getTitle());
          //拿到商品详细
          this.shopProduct = productService.searchProducts(shopProduct.getProductid());
           
          int num =shopProduct.getNum().intValue();
          shopCart.setNum(num);
          shopCart.setCover(shopProduct.getCover());
          cartService.insertCart(shopCart);
          
          //更新关联的订单
          double amount = searchOrder.getAmount()+shopProduct.getPrice();
          searchOrder.setAmount(amount); 
          searchOrder = orderService.updateOrder(searchOrder);
          
          //页面中显示购物中的商品种类的数量
          List<ShopCart> resultCart2 = cartService.searchCartByUserid(userid);
          if(resultCart2!=null){
            HttpSession session = ServletActionContext.getRequest().getSession();
            session.setAttribute("cartNum",resultCart2.size());
            
            map.put("cartNum",resultCart2.size());
          }
          
        }
        
      }else{//若没有未支付的订单，则生成一个新的订单，保存订单和订单详细，和新的购物车
        
        //先生成有一个新的订单并保存， 插入用户id
    	shopOrder = new ShopOrder();
        System.out.println("用户没有未支付的订单，创建一个新的订单....");
        System.out.println("user中的userid:"+user.getUserid());
        shopOrder.setShopUser(user);
        System.out.println("shopOrder中的userid:"+shopOrder.getShopUser().getUserid());
        shopOrder = orderService.insertOrder(shopOrder);//新建一个订单
        System.out.println("保存后是否会放回新的订单号："+shopOrder.getOrderid());
        
        //在生成一个新的订单详细并保存，插入订单和商品，传进商品的title、id、price
        System.out.println("商品信息：1、"+shopProduct.getProductid());
        System.out.println("2、"+shopProduct.getTitle());
        System.out.println("3、"+shopProduct.getPrice());
        
        shopOrderDetail = new ShopOrderDetail();
        shopOrderDetail.setShopProduct(shopProduct);
        shopOrderDetail.setPrice(shopProduct.getPrice());
        shopOrderDetail.setProductnum(1);
        shopOrderDetail.setShopOrder(shopOrder);
        
        System.out.println("订单号："+shopOrderDetail.getShopOrder().getOrderid());
        System.out.println("商品名称："+shopOrderDetail.getShopProduct().getTitle());
        System.out.println("商品单价："+shopOrderDetail.getShopProduct().getPrice());
        System.out.println("商品数量："+shopOrderDetail.getProductnum());
        shopOrderDetail = orderDetailService.insertOrderDetail(shopOrderDetail);
          
        //新增一个购物车商品行
        shopCart = new ShopCart();
        shopCart.setShopUser(user);
        shopCart.setShopProduct(shopProduct);
        shopCart.setProductnum(1);
        shopCart.setPrice(shopProduct.getPrice());
        shopCart.setTitle(shopProduct.getTitle());
       
        int num =shopProduct.getNum().intValue();
        shopCart.setNum(num);
        shopCart.setCover(shopProduct.getCover());
        cartService.insertCart(shopCart);
        
        //更新订单总价
        shopOrder.setAmount(shopProduct.getPrice());
        shopOrder = orderService.updateOrder(shopOrder);
        
        //更新页面内商品种类的数量
        List<ShopCart> resultCart2 = cartService.searchCartByUserid(userid);
        if(resultCart2!=null){
          HttpSession session = ServletActionContext.getRequest().getSession();
          session.setAttribute("cartNum",resultCart2.size());
          
          map.put("cartNum",resultCart2.size());
        }
        
      }
      System.out.println("添加结束");
      map.put("status", 0);
    
      ResultUtils.toJson(ServletActionContext.getResponse(), map);
      return this.SUCCESS;
      
    }else{ 
      return this.INPUT;
    }
    
  }
  
  //查询未支付的订单
  public String FindNotPayOrder() throws Exception{//查询未支付订单
    
    //先检查用户是否登录
    //获取？后面的参数
    HttpServletRequest request = ServletActionContext.getRequest();
    String userid = request.getQueryString();
    System.out.println(userid);
    
    if(userid.equals("null")){
      return this.INPUT;
    }else{
      
    //通过用户id和status=0查询未支付订单
    List<ShopOrder> result = orderService.searchOrder(userid, "0");
    ShopOrder notPayOrder = new ShopOrder(); 
    if(result!=null){
      System.out.println("获得未支付订单");
      notPayOrder = result.get(0);
    }else{ 
      System.out.println("所有订单都已经支付,跳转到空购物车页面");
      notPayCart = null ;
      return "emptyCart";
    }
    
   
      this.notPayCart = 
          cartService.searchCartByUserid(userid);
 
     
    return this.SUCCESS;
    }
  }
  
  //得到地址，并得到总价
  public String Accounts() throws Exception{
    
    //查询未支付的订单
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = ServletActionContext.getRequest().getSession();
    String userid = request.getQueryString();
    List<ShopOrder> result = orderService.searchOrder(userid,"0");
    ShopOrder searchOrder = result.get(0);
    session.setAttribute("accounts",searchOrder.getAmount());
    
    List<ShopProfile> profile = profileService.searchOneProfile(userid);
    if(profile==null){
      shopProfile = new ShopProfile();
    }
    else{
      shopProfile = profile.get(0);
    }
    
    return this.SUCCESS;
  }
  
  //提交确认地址，并更新订单状态，更新库存
  public String Address() throws Exception{
    
    System.out.println(shopProfile.getShopUser().getUserid());
    
    if(shopProfile.getShopUser().getUserid()!=null){
      
      String userid = Long.toString(shopProfile.getShopUser().getUserid());
      List<ShopOrder> result = orderService.searchOrder(userid,"0");
  
       
      ShopOrder searchOrder = result.get(0);
      searchOrder.setAddress(province+city+addressDetails);
      
      //先查找有没有
      List<ShopProfile> listProfile = profileService.searchOneProfile(userid);
        ShopProfile resultProfile = null ;
      if(listProfile!=null){
        resultProfile = listProfile.get(0);
      }
      if(resultProfile!=null){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date test = sdf.parse("2017-05-22");
        resultProfile.setTruename(shopProfile.getTruename());
        resultProfile.setPhone(shopProfile.getPhone());
        profileService.updateProfile(resultProfile);
      }else{
        profileService.insertProfile(shopProfile);
      }

      //更新表单
      searchOrder.setStatus(1);
      searchOrder.setUpdateTime(new Timestamp(System.currentTimeMillis()));
      searchOrder = orderService.updateOrder(searchOrder);
      
      //根据更新的表单来更新库存
      String orderid = Long.toString(searchOrder.getOrderid());
      String updatetime = searchOrder.getUpdateTime().toString();
      //result = orderService.searchOrderByTime(orderid, updatetime);
      List<ShopOrderDetail> resultDetail = orderDetailService.searchAllOrderDetail(orderid);
      
      Iterator it = resultDetail.iterator();
      int i = resultDetail.size()-1 ;
      ShopOrderDetail updateDetail = null;
      while(i>=0){
        updateDetail = resultDetail.get(i);
        long num = updateDetail.getProductnum();
        ShopProduct updateProduct = null ;
        updateProduct = updateDetail.getShopProduct();
        long amount = updateProduct.getNum()-num;
        updateProduct.setNum(amount);
        productService.updateProduct(updateProduct);
        i--;
      }
      
      //删除掉购物车
      cartService.delCart(userid);
      
      return this.SUCCESS;
    }else{
      return this.INPUT;
    }
  }
  
  //删除订单中某一个商品
  public String DelOneInCart() throws Exception{
    
    //首先获得购物车中该行的信息
    Map<String, String> param = new HashMap<String, String>();
	HttpServletRequest request = ServletActionContext.getRequest();
	Map<String, String[]> params = request.getParameterMap();
	for (String key : params.keySet()) {
		String[] values = params.get(key);
		for (int i = 0; i < values.length; i++) {
			param.put(key, values[i]);

		}
	}
	  
	Map<String, Object> map = new HashMap<String, Object>();
	if (param.get("userid") == "null") {
		map.put("status", -1);
		ResultUtils.toJson(ServletActionContext.getResponse(), map);
		return null;
	}
	
	
	String userid = param.get("userid");//用户编号
    String cartid = param.get("cartid");//该行购物车编号
    map.put("userid",userid);
    System.out.println("cartid:"+cartid);
    shopCart = cartService.searchOneCartByCartId(cartid);
     
    //在找到该订单
    List<ShopOrder> list = orderService.searchOrder(userid, "0");
    shopOrder = list.get(0);
    //再通过订单号和商品号确定唯一的订单详细
    String productid = Long.toString(shopCart.getShopProduct().getProductid());
    String orderid = Long.toString(shopOrder.getOrderid());
    List<ShopOrderDetail> list2 = orderDetailService.searchOrderDetail(orderid, productid);
    shopOrderDetail = list2.get(0);
     
    //先更新订单，再删除购物车和订单详细
    double amount = shopOrder.getAmount()-shopOrderDetail.getPrice()*shopOrderDetail.getProductnum();
    shopOrder.setAmount(amount);
    orderService.updateOrder(shopOrder);
    
    boolean is = cartService.delOneCart(shopCart.getCartid());
    if(is){
      System.out.println("删除该行成功");
    }else{
      System.out.println("删除该行失败");
    }
    
    boolean is2 = orderDetailService.delOneDetail(shopOrderDetail.getDetailid());
    
    if(is2){
      System.out.println("删除该行成功");
    }else{
      System.out.println("删除该行失败");
    }
    
    if(amount==0)
      orderService.delByorderid(shopOrder);
    
    List<ShopCart> resultCart2 = cartService.searchCartByUserid(userid);
    HttpSession session = ServletActionContext.getRequest().getSession();
    if(resultCart2!=null){
      session.setAttribute("cartNum",resultCart2.size());
      map.put("cartNum",resultCart2.size());
    }else{
      session.setAttribute("cartNum",0);
      map.put("cartNum",0);
    }
    
    this.pageCartBean = cartService.queryForPage(userid,5,page);
    this.notPayCart = this.pageCartBean.getList();
    
    map.put("status", 0);
    ResultUtils.toJson(ServletActionContext.getResponse(), map);
   
    
    return this.SUCCESS;
  }
  
  
  //增加购物车中的某件商品
  public String AddToCart() throws Exception{
    
	// 获取post请求的数据
	Map<String, String> param = new HashMap<String, String>();
	HttpServletRequest request = ServletActionContext.getRequest();
	Map<String, String[]> params = request.getParameterMap();
	for (String key : params.keySet()) {
		String[] values = params.get(key);
		for (int i = 0; i < values.length; i++) {
			param.put(key, values[i]);

		}
	}
	  
	Map<String, Object> map = new HashMap<String, Object>();
	if (param.get("userid") == "null") {
		map.put("status", -1);
		ResultUtils.toJson(ServletActionContext.getResponse(), map);
		return null;
	}
	
	
	String userid = param.get("userid");//用户编号
	String productid = param.get("productid");//商品编号
	 
	user = userService.getUserByUserId(Long.parseLong(userid));
	shopProduct = productService.searchProducts(Long.parseLong(productid));
    
    //找到订单，购物车，订单详细
    List<ShopOrder> list = orderService.searchOrder(userid, "0");
    shopOrder = list.get(0);
    
    String orderid = Long.toString(shopOrder.getOrderid());
    List<ShopOrderDetail> list2 = orderDetailService.searchOrderDetail(orderid, productid);
    shopOrderDetail = list2.get(0);
    
    List<ShopCart> list3 = cartService.searchCartAboutProduct(userid, productid);
    shopCart = list3.get(0);
    
    int num = shopOrderDetail.getProductnum()+1;
     
    if( num <= shopCart.getNum()){//不超出库存
    
      shopOrderDetail.setProductnum(num);
      shopCart.setProductnum(num);
      double amount = shopOrder.getAmount()+shopOrderDetail.getPrice();
      shopOrder.setAmount(amount);
      
      orderService.updateOrder(shopOrder);
      orderDetailService.updateOrderDetail(shopOrderDetail);
      cartService.updateCart(shopCart); 
      
     
    }
    List<ShopCart> resultCart2 = cartService.searchCartByUserid(userid);
    HttpSession session = ServletActionContext.getRequest().getSession();
    if(resultCart2!=null){
      session.setAttribute("cartNum",resultCart2.size());
      map.put("cartNum",resultCart2.size());
    }else{
      session.setAttribute("cartNum",0);
      map.put("cartNum",0);
    }
    
    
    this.pageCartBean = cartService.queryForPage(userid,5,page);
    this.notPayCart = this.pageCartBean.getList();
    
    map.put("status", 0);
    ResultUtils.toJson(ServletActionContext.getResponse(), map);
    
    return this.SUCCESS;
  }
  
  //减少购物车中的某件商品
  public String DelToCart() throws Exception{
	  
	// 获取post请求的数据
	Map<String, String> param = new HashMap<String, String>();
	HttpServletRequest request = ServletActionContext.getRequest();
	Map<String, String[]> params = request.getParameterMap();
	for (String key : params.keySet()) {
		String[] values = params.get(key);
		for (int i = 0; i < values.length; i++) {
			param.put(key, values[i]);

		}
	}
	  
	Map<String, Object> map = new HashMap<String, Object>();
	if (param.get("userid") == "null") {
		map.put("status", -1);
		ResultUtils.toJson(ServletActionContext.getResponse(), map);
		return null;
	}
	
	
	String userid = param.get("userid");//用户编号
	map.put("userid",userid);
	String productid = param.get("productid");//商品编号
	 
	user = userService.getUserByUserId(Long.parseLong(userid));
	shopProduct = productService.searchProducts(Long.parseLong(productid));
    
    //找到订单，购物车，订单详细
    List<ShopOrder> list = orderService.searchOrder(userid, "0");
    shopOrder = list.get(0);
    
    String orderid = Long.toString(shopOrder.getOrderid());
    List<ShopOrderDetail> list2 = orderDetailService.searchOrderDetail(orderid, productid);
    shopOrderDetail = list2.get(0);
    
    List<ShopCart> list3 = cartService.searchCartAboutProduct(userid, productid);
    shopCart = list3.get(0);
    
    int num = shopOrderDetail.getProductnum()-1;
     
    double amount = (shopOrder.getAmount()-shopOrderDetail.getPrice());
    
    shopOrder.setAmount(amount);
    orderService.updateOrder(shopOrder);
    
    if( num == 0 ){
      System.out.println("删除购物车和订单详细");
      cartService.delOneCart(shopCart.getCartid());
      orderDetailService.delOneDetail(shopOrderDetail.getDetailid());
      HttpSession session = ServletActionContext.getRequest().getSession();
      List<ShopCart> resultCart2 = cartService.searchCartByUserid(userid);
      
      if(amount==0)
         orderService.delByorderid(shopOrder);
      
      if(resultCart2!=null){
    	map.put("cartNum", resultCart2.size());
        session.setAttribute("cartNum",resultCart2.size());
      }else{
    	map.put("cartNum", 0); 
        session.setAttribute("cartNum",0);
      }
      
     
    }else{
      shopOrderDetail.setProductnum(num);
      shopCart.setProductnum(num);
      orderDetailService.updateOrderDetail(shopOrderDetail);
      cartService.updateCart(shopCart); 
    }
    
     
    this.pageCartBean = cartService.queryForPage(userid,5,page);
    this.notPayCart = this.pageCartBean.getList();
    
    map.put("status", 0);
    ResultUtils.toJson(ServletActionContext.getResponse(), map);
    return this.SUCCESS;
  }
  
  //购物车列表-分页
  public String CartList() throws Exception{
	  
	  HttpServletRequest request = ServletActionContext.getRequest();
	  String userid = request.getParameter("userid");
	  page = Integer.valueOf(request.getParameter("page")).intValue();
	  this.pageCartBean = cartService.queryForPage(userid,5,page);
	  this.notPayCart = this.pageCartBean.getList();
	  
	  return this.SUCCESS;
  }
  
  //显示订单表
  public String orderList() throws Exception {
		this.pageOrderBean = orderService.queryForPage(5, page);// 获取封装了分页信息和数据的pageBean
		this.listOrder = this.pageOrderBean.getList(); // 获取数据
		return SUCCESS;
  }
  
  //订单详细信息
  public String orderDetail() throws Exception {

		if (orderid == 0) {
			shopOrder = null;
			return SUCCESS;
		}

		this.shopOrder = orderService.searchOrderByOrderId(orderid);
				 
		// System.out.println(this.user);
		if (this.shopOrder != null) {
			return SUCCESS;
		}
		return ERROR;
	}

	public String orderUpdate() throws Exception {

		// 获取post请求的数据
		Map<String, String> param = new HashMap<String, String>();
		HttpServletRequest request = ServletActionContext.getRequest();
		Map<String, String[]> params = request.getParameterMap();
		for (String key : params.keySet()) {
			String[] values = params.get(key);
			for (int i = 0; i < values.length; i++) {
				param.put(key, values[i]);

			}
		}
		
		Map<String, Object> map = new HashMap<String, Object>();
		if (param.get("id") == "") {
			map.put("status", -1);
			ResultUtils.toJson(ServletActionContext.getResponse(), map);
			return null;
		}
		
		this.orderid = Long.parseLong(param.get("id"));
		ShopOrder order = orderService.searchOrderByOrderId(this.orderid);
				 
	
		// 实例化
		order.setAddress(param.get("address"));
		order.setExpress(param.get("express"));
		order.setExpressno(param.get("expressno"));
		order.setTradeno(param.get("tradeno"));		
		
		if(orderService.updateOrder(order)!=null){
			map.put("status", 0);
		}else{
			map.put("status", -1);
		}

		ResultUtils.toJson(ServletActionContext.getResponse(), map);
		return null;
	}
  
/********************************Setting页的action*************************************/	
	public String showSettionInfo(){
		 //先检查用户是否登录
	    //获取？后面的参数
	    HttpSession session = ServletActionContext.getRequest().getSession();
	    
	    
	    if(session.getAttribute("userid")==null){
	      return this.INPUT;
	    }else{
	      
	    //通过用户id和status=0查询未支付订单
	    String userid=new String();
	    userid=session.getAttribute("userid").toString();	    
	    setting_NotPayOrder = orderService.searchOrder(userid);
	    if(null==setting_NotPayOrder||setting_NotPayOrder.size()==0){
	      System.out.println("没有未支付的订单");
	      setting_NotPayOrder = null ;
	    }else{ 
	      System.out.println("获得已支付订单");
	      System.out.println(setting_NotPayOrder);
	      
	    }
	    
	   
	 
	     
	    return "Setting";
	    }
	}
/*********************************getter,setter*****************************************/
  public ShopOrder getShopOrder() {
    return shopOrder;
  }

  public List<ShopOrder> getSetting_PayOrder() {
	return setting_PayOrder;
}

public void setSetting_PayOrder(List<ShopOrder> setting_PayOrder) {
	this.setting_PayOrder = setting_PayOrder;
}

public List<ShopOrder> getSetting_NotPayOrder() {
	return setting_NotPayOrder;
}

public void setSetting_NotPayOrder(List<ShopOrder> setting_NotPayOrder) {
	this.setting_NotPayOrder = setting_NotPayOrder;
}

public int getSelectFalg() {
	return selectFalg;
}

public void setSelectFalg(int selectFalg) {
	this.selectFalg = selectFalg;
}

public void setShopOrder(ShopOrder shopOrder) {
    this.shopOrder = shopOrder;
  }

  public ShopUser getUser() {
    return user;
  }

  public void setUser(ShopUser user) {
    this.user = user;
  }

  public ShopProduct getShopProduct() {
    return shopProduct;
  }

  public void setShopProduct(ShopProduct shopProduct) {
    this.shopProduct = shopProduct;
  }

  public ShopOrderDetail getShopOrderDetail() {
    return shopOrderDetail;
  }

  public void setShopOrderDetail(ShopOrderDetail shopOrderDetail) {
    this.shopOrderDetail = shopOrderDetail;
  }


  public String getProvince() {
    return province;
  }

  public void setProvince(String province) {
    this.province = province;
  }

  public String getCity() {
    return city;
  }

  public void setCity(String city) {
    this.city = city;
  }

  public String getAddressDetails() {
    return addressDetails;
  }

  public void setAddressDetails(String addressDetails) {
    this.addressDetails = addressDetails;
  }

  public ShopProfile getShopProfile() {
    return shopProfile;
  }

  public void setShopProfile(ShopProfile shopProfile) {
    shopProfile = shopProfile;
  }

  public ShopCart getShopCart() {
    return shopCart;
  }

  public void setShopCart(ShopCart shopCart) {
    this.shopCart = shopCart;
  }

  public List<ShopCart> getNotPayCart() {
    return notPayCart;
  }

  public void setNotPayCart(List<ShopCart> notPayCart) {
    this.notPayCart = notPayCart;
  }

  public int getCartNum() {
    return cartNum;
  }

  public void setCartNum(int cartNum) {
    this.cartNum = cartNum;
  }

	public PageCartBean getPageCartBean() {
		return pageCartBean;
	}

	public void setPageCartBean(PageCartBean pageCartBean) {
		this.pageCartBean = pageCartBean;
	}
	
	public int getPage() {
		return page;
	}
	
	public void setPage(int page) {
		this.page = page;
	}

	public PageOrderBean getPageOrderBean() {
		return pageOrderBean;
	}

	public void setPageOrderBean(PageOrderBean pageOrderBean) {
		this.pageOrderBean = pageOrderBean;
	}

	public List<ShopOrder> getListOrder() {
		return listOrder;
	}

	public void setListOrder(List<ShopOrder> listOrder) {
		this.listOrder = listOrder;
	}

	public long getOrderid() {
		return orderid;
	}

	public void setOrderid(long orderid) {
		this.orderid = orderid;
	}
  
  

}
